package cn.zqh.minio.controller;

import cn.zqh.bean.api.CommonResult;
import cn.zqh.minio.service.FileService;
import cn.zqh.minio.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
     * @Author: zqh
     * @Date: 2022-10-20-9:45
     * @Description: 文件上传$
     */
    @Api("文件上传")
    @RestController
    @RequestMapping("/minio")
//    @CrossOrigin
    public class MinioController {

        @Autowired
        private FileService fileService;

        @PostMapping("/upload")
        @ApiOperation(value = "文件上传")
        public CommonResult upload(MultipartFile file){
            return fileService.upload(file);
        }

        @DeleteMapping("delPictureByName")
        @ApiOperation(value = "通过文件的名字删除文件")
        public CommonResult delPictureByName(String fileName){
            return fileService.delPictureByName(fileName);
        }
    }
